package com.flitsneak.designpatterns.creationalpatterns.factory.factorymethod.breakfastshop;

import com.flitsneak.designpatterns.creationalpatterns.factory.factorymethod.AbstractBreakfastShop;
import com.flitsneak.designpatterns.creationalpatterns.factory.factorymethod.Breakfast;

/**
 * Author: flitsneak
 * Date: 2022/5/31 17:52
 * Description:
 */
public class TraditionalBreakfastShop extends AbstractBreakfastShop {
    @Override
    public <T extends Breakfast> T makeBreakfast(Class<T> clazz) {
        Breakfast traditionalBreakfast = null;

        try {
            traditionalBreakfast = (T) Class.forName(clazz.getName()).getDeclaredConstructor().newInstance();
        } catch (Exception e) {
            System.out.println("没有此配方！");
        }

        return (T) traditionalBreakfast;
    }
}
